<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>props使用</title>
</head>
<body>
  <!-- 准备容器 -->
  <div id="test"></div>
  <div id="test1"></div>
  <!-- 按照顺序引入 -->
  <script type="text/javascript" src="../../js/react.development.js"></script>
  <script type="text/javascript" src="../../js/react-dom.development.js"></script>
  <script type="text/javascript" src="../../js/babel.min.js"></script>
  <!-- 引入prop-types用于对组件标签属性进行限制 -->
  <script type="text/javascript" src="../../js/prop-types.js"></script>
  <script type="text/babel" >
    function Person(props) {
      const {name,age,sex} =props
      return (
        <ul>
          <li>姓名：{name}</li>  
          <li>性别：{sex}</li>  
          <li>年龄：{age}</li>  
        </ul>
      )
    }
    Person.propTypes = { // propTypes  react组件要求 p小写
      name:PropTypes.string.isRequired,  // PropTypes 引入的组件库 P大写
      sex:PropTypes.string,
      age:PropTypes.number,
    }
    Person.defaultProps={
      sex:'人妖',
      age:18
    }
    // 组件标签的所有属性都保存在props中
    ReactDOM.render(<Person name='tom' sex='男' age={18}/>,document.getElementById('test'))
  </script>
</body>
</html>